#ifndef MYDATABASE_H
#define MYDATABASE_H

#include <QObject>
#include <QSqlDatabase>
#include "weightdata.h"

class MyDatabase : public QObject
{
    Q_OBJECT
public:
    explicit MyDatabase(QObject *parent = nullptr);
    // 判断 SQLite 数据库是否存在，不存在则创建
    bool checkOrCreateDatabase();
    //Q_INVOKABLE QList<weightdata*> getWeightData();
    //QSqlDatabase initialDatabase();
    //void closeDatabase(QSqlDatabase db);
    bool existTable(QSqlDatabase db, QString tableName);
    bool existColumn(QSqlDatabase db, QString tableName, QString columnName);
    void openDB();
    void closeDB();
    //QList<weightdata*> weightData() const;
private:
    //QList<weightdata*> m_weightdata;
    QSqlDatabase m_db;
    QString m_clientID;
    QString m_deviceType;
};

#endif // MYDATABASE_H
